草庐IT

php mvc 和 .htaccess url 重写

全部标签

php - 使用重写引擎时正确编码 url

我正在使用从Akelos框架中提取的mod_rewrite和路由系统。我在搜索关键参数中使用一些符号时遇到了一个非常大的问题。路由映射如下:$map->connect(":lang/search/:string",array('controller'=>'search','action'=>'index'));现在在Controller中,我将$this->registry->map['params']['get']['string']作为搜索关键字。我找不到正确编码url的方法。例如,我们取一个字符串t\/#%&=urlencode()给出t%5C+%2F%23%25%26%3D页面

php - htaccess - 重写具有相同名称目录的文件

我的网站有多个同名的PHP文件和目录,如下所示:/projects.php/projects/projects/something.php我已经设法做到了http://example.com/projects重写为http://example.com/projects.php遵循以下规则(使用答案here):RewriteEngineOn#DisableautomaticdirectorydetectionDirectorySlashOff#HideextensionRewriteCond%{REQUEST_FILENAME}\.php-fRewriteRule^(.*)$$1.php

php - .htaccess 已被读取但重写 url 不起作用

httpd.conf中rewrite的模块如下:LoadModulerewrite_modulemodules/mod_rewrite.so.htaccess的路径:c:\wamp\www\magentodev\.htaccess因此在.htacess中我有这个:Options+FollowSymLinksRewriteEngineonRewriteCond%{REQUEST_URI}^/boombottleh2o\+?$RewriteRule(.*)/gu/boombottleh2o.php[NC,L,QSA]//someotherones我希望尝试:localhost/magent

php - 在 PHP 中访问父属性和重写的方法

我有如下父类和子类:abstractclassParentObj{private$data;publicfunction__construct(){$this->data=array(1,2,3);var_dump($this->data);$this->method();}publicfunctionmethod(){echo"ParentObj::method()";}}classChildObjextendsParentObj{publicfunction__construct(){parent::__construct();var_dump($this->data);}publ

PHP在不重写文件的情况下将数据写入文件中间的最佳方法是什么

我正在使用php(1GB+)处理大型文本文件,我正在使用file_get_contents("file.txt",NULL,NULL,100000000,100);要从文件中间获取数据,但如果我想将文件中的数据更改为与原始数据不同的内容,我将不得不重写整个文件。如果数据大于原始数据,如何在不覆盖数据的情况下更改文件(可变长度)中的数据?我保留了文件中不同数据block的索引及其字节位置。似乎唯一的选择是为每条数据分配x个字节,然后在我想更改它时重写该block……问题是它会占用比所需空间更多的空间空字节,并且写入需要更长的时间...并且仍然无法解决如何“删除”数据的问题,因为文件的大小

php - .htaccess 重写 : subdomain as GET var and path as GET var

期望的结果:http://example.com/->index.phphttp://www.example.com/->index.phphttp://hello.example.com/->index.php?subdomain=hellohttp://whatever.example.com/->index.php?subdomain=whateverhttp://example.com/world->index.php?path=worldhttp://example.com/world/test->index.php?path=world/testhttp://hello.e

php - Apache URL 重写功能不正常

我正在尝试使用apache-rewrite规则来转换以下URL:http://localhost/foo/bar/news.php?id=24转换成这种格式:http://localhost/foo/bar/news/foo-bar24是MySQL表中随机行的id,它还包含title和content字段。MariaDB[blog]>select*fromarticles;+----+---------+----------+|id|title|content|+----+---------+----------+|1|foo-bar|blabla|+----+---------+---

php - .htaccess 重写规则在 Mac 上无法正常工作

我在我的macbookproleopard上有一个网站项目,我正在使用内置的apache2和php。我已经在httpd.conf和user.conf中进行了配置以使用htaccess。所做的更改如下:LoadModulerewrite_module/usr/lib/apache2/modules/mod_rewrite.soAllowOverrideAll问题是当我想打开一个网站时localhost/~username/site/site/index.php/welcome,index.php做了一些操作,找到了正确的Controller和正确的页面。但是当我尝试进入像site/wel

php - URL 重写 OpenCart 产品 SEO

我想从我的opencart网上商店重写我的产品url。Opencart本身有一个非常糟糕的seo实现。我已经更新了seo实现,以便能够对多个类别使用相同的关键字,请参阅:OpencartduplicateURLkeywords但这仅适用于类别。对于我认为的产品,我只需要一个htaccess重写规则。原始网址如下所示:http://domain.com/index.php?route=product/product&path=25_28_93&product_id=1759我的网址现在看起来像这样:http://domain.com/In-Stock/Retreaded-Tires/Ag

php - Magento - URL 重写或重定向问题

我在Magento版本1.9.1.0中运行一个启用了SSL的站点。当我在刷新浏览器缓存后或在私有(private)模式下在浏览器上打开该网站的管理面板时,它第一次显示网站的主页而不是管理员登录页面,即sitename.com/adminURL重定向到https://sitename.com第一次自动生成URL。我第一次尝试直接访问网站内页时发生了同样的问题。在此之后,当我在浏览器的地址栏中再次输入URL作为sitename.com/admin时,它会打开管理员登录页面,这在下次很好(似乎缓存有效)。我在我的Magento站点中使用LoginandPaywithAmazon扩展程序。因此